#ifndef __ARQ_RINGBUFFER_H__
#define __ARQ_RINGBUFFER_H__

#include <stddef.h>
#include <stdint.h>

template <typename T, size_t RING_BUFFER_SIZE>
class CARQRingBuffer
{
    static constexpr size_t RING_BUFFER_INDEX_MASK = RING_BUFFER_SIZE - 1;
public:
    
    void Push(const T* pstData)
    {
        m_arrItem[m_uiTail++&RING_BUFFER_INDEX_MASK] = pstData;
        m_uiTail++;
    }

    T* Pop()
    {
        return m_arrItem[m_uiHead++&RING_BUFFER_INDEX_MASK];
    }

    void SetItem(uint32_t uiSeqNo, const T* pstData)
    {
        m_arrItem[uiSeqNo & RING_BUFFER_INDEX_MASK] = pstData;
    }

    
private:
    uint32_t m_uiTail = 0;
    uint32_t m_uiHead = 0;
    T* m_arrItem[RING_BUFFER_SIZE];
};

#endif //__ARQ_RINGBUFFER_H__